package com.xinchuang.controller.targetSystem.damage;

import com.xinchuang.comment.R;
import com.xinchuang.common.Result;
import com.xinchuang.dto.DeleteDto;
import com.xinchuang.entity.targetSystem.damage.Missile;
import com.xinchuang.service.targetSystem.damage.MissileService;
import com.xinchuang.vo.MissileVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chenyanming
 * @program systems-analysis
 * @description 导弹管理
 * @date 2024/05/15
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/missile")
@Api(value = "DD管理", tags = "DD管理")
public class MissileController {

    @Autowired
    private MissileService missileService;

    @ApiOperation(value = "添加或修改导弹数据")
    @PostMapping("/addAndUpdateMissile")
    public Result addAndUpdateMissile(@RequestBody MissileVo missile) {
        return missileService.addAndUpdateMissile(missile);
    }

    /**
     * @param pageNum     页码
     * @param pageSize    页数
     * @param missileName DD名称
     * @param missileType DD类型
     * @return
     */
    @ApiOperation(value = "分页查询列表数据")
    @GetMapping("/queryList")
    public R queryList(@RequestParam(value = "pageNum") Integer pageNum,
                       @RequestParam(value = "pageSize") Integer pageSize,
                       @RequestParam(value = "missileName", required = false) String missileName,
                       @RequestParam(value = "missileType", required = false) String missileType) {
        return R.data(missileService.queryList(pageNum, pageSize, missileName, missileType));
    }

    /**
     * 根据ids批量删除
     *
     * @return
     */
    @ApiOperation(value = "根据ids删除/批量删除数据")
    @DeleteMapping("/deleteByIds")
    public R deleteByIds(@RequestParam(value = "deleteStatus") boolean deleteStatus,
                         @RequestParam(value = "ids[]") String id) {
        return missileService.deleteByIds(id, deleteStatus);
    }

    @ApiOperation(value = "DD字典下拉列表")
    @GetMapping("/getList")
    public R getList() {
        return R.data(missileService.getList());
    }
}
